package cn.bdqn.t354.service.impl;

import cn.bdqn.t354.mapper.PlanMapper;
import cn.bdqn.t354.pojo.Plan;
import cn.bdqn.t354.service.PlanService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class PlanServiceImpl implements PlanService {
    @Resource
    private PlanMapper planMapper;

    @Override
    public List<Plan> getPlanByChcId(Long chcId) {
        QueryWrapper<Plan> qw = new QueryWrapper<>();
        qw.eq("pla_chc_id", chcId);
        return planMapper.selectList(qw);
    }

    @Override
    public void addPlan(Plan plan) {
        plan.setPlaDate(new Date());
        planMapper.insert(plan);
    }

    @Override
    public void updatePlan(Plan plan) {
        planMapper.updateById(plan);
    }

    @Override
    public void deletePlan(Long id) {
        planMapper.deleteById(id);
    }
}
